package com.slt.android.screenshot;

import android.app.IntentService;
import android.content.Intent;
import android.support.annotation.Nullable;
import android.util.Log;

import java.io.File;

/**
 * Created by dp on 2018/5/9.
 */

public class ClickService extends IntentService {

    public static final String TAG = "ClickService";


    public ClickService() {
        super("ClickService");
    }

    /**
     * Creates an IntentService.  Invoked by your subclass's constructor.
     *
     * @param name Used to name the worker thread, important only for debugging.
     */
    public ClickService(String name) {
        super("ClickService");
    }


    @Override
    public void onCreate() {
        Log.e(TAG, "onCreate");
        super.onCreate();
    }

    @Override
    protected void onHandleIntent(@Nullable Intent intent) {

        while (!getBooleanFlag()) {
            ClickUtil.onClick();
            try {
                Thread.sleep(1000 * 5);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    private boolean getBooleanFlag() {

        boolean b = AbSharedUtil.getBoolean(this, "exitFlag", false);
        return b;
    }
}
